//
//  DispatchTableCell.m
//  cocoapodText
//
//  Created by apple on 16/10/19.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ShiPei.h"
#import "DispatchTableCell.h"
#import <Foundation/Foundation.h>


@interface DispatchTableCell()
@property(nonatomic,strong) DispatchTableCellView *tableCellView;
@end

@implementation DispatchTableCell

//重写构造方法，让自定义的cell一创建出来就有四个子控件
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setFrame:[ShiPei CGRectMakeScale:0 :0 :800 :35]];
        
        DispatchTableCellView *tableCellView=[[DispatchTableCellView alloc] initWithFrame:[ShiPei CGRectMakeScale:0 :0 :800 :35]];
        [self addSubview:tableCellView];
        [tableCellView setBackgroundColor:[UIColor clearColor]];
        self.tableCellView=tableCellView;
        
    }
    return self;
}

/**
 *  重写set方法
 *
 *  @param car
 */
-(void)setDispatchinfo:(dispatchInfo *)dispatchinfo{
    //不要忘了，记录传递进来的模型
    _dispatchinfo=dispatchinfo;
    //给子控件赋值数据
    [self settingData];
}

/**
 *  对子控件的数据进行设置
 */
-(void)settingData{
    if ([_dispatchinfo.color isEqualToString:@"0"]) {
        [self setBackgroundColor:FUIColorFromRGB(0xf0f4f7)];
    }else{
        [self setBackgroundColor:[UIColor whiteColor]];
    }
    [_tableCellView setName:_dispatchinfo.name];
    [_tableCellView setType:_dispatchinfo.type];
    [_tableCellView setLoad:_dispatchinfo.load];
    [_tableCellView setNumber:_dispatchinfo.number];
    [_tableCellView setStartTime:_dispatchinfo.startTime];
    [_tableCellView setEndTime:_dispatchinfo.endTime];
    [_tableCellView setContent:_dispatchinfo.content];
    [_tableCellView setPrice:_dispatchinfo.price];
}

@end

